package com.mrx.compose.test.config

import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.loadSvgPainter
import androidx.compose.ui.unit.Density
import java.io.InputStream
import java.net.URL

@Suppress("SameParameterValue", "unused")
object WindowConfig {

    val image = loadResourceImage("/logo.svg")

    private fun loadImage(inputStream: InputStream): Painter {
        return inputStream.use { loadSvgPainter(it, Density(1.0F)) }
    }

    private fun loadVueLogo(): Painter {
        return loadImage(URL("https://v2.cn.vuejs.org/images/logo.svg").openStream())
    }

    private fun loadResourceImage(resource: String): Painter {
        return loadImage(WindowConfig::class.java.getResourceAsStream(resource)!!)
    }

}